import { Table,Tabs, Form,  Button, Modal, message,Dropdown,Menu ,Icon} from 'antd';
import { inject, observer} from 'mobx-react';
import {routerShape} from 'react-router';
import {WeaTop,WeaRightMenu,WeaLocaleProvider,WeaNewScroll} from 'ecCom'
import {Condition,GetAdButtons,ConditionNum} from '../list/listCondition'
const getLabel = WeaLocaleProvider.getLabel;

@inject("taskStore")
@observer
class TaskSearch1 extends React.Component {
    static contextTypes = {
        router: routerShape
    }
    constructor(props) {
        super(props);
    }
    componentDidMount  = () => {
        const {taskStore} = this.props;
        //设置dataType
        // const preDataType = this.props.location.query.dataType;
        taskStore.setDataType("1");
        taskStore.init({ "isSuper":"1","isSuperPage":true,"fromSuperPage":false,"selectedTreeKey":0});
    }
    componentWillReceiveProps = (nextProps) => {
        if(nextProps.location.key != this.props.location.key){
            const {taskStore} = nextProps;
            //设置dataType
            // const nextDataType = nextProps.location.query.dataType;
            taskStore.setDataType("1");
            taskStore.init({ "isSuper":"1","isSuperPage":true,"fromSuperPage":false,"selectedTreeKey":0});
        }
    }
    render() {
        const {taskStore} = this.props;
        const {status,tasklabels,form,formB} = taskStore;
        const {loading} = status;
        const {topIcon="icon-coms-government" ,iconBgcolor="#f14a2d"} = tasklabels;
        let height = document.body.clientHeight;
        return (
            <div className='g-taskSearch'>
                <WeaRightMenu ecId={`${this && this.props && this.props.ecId || ''}_WeaRightMenu@zel21f`} datas={this.getRightMenu()} style={{color:"#ccc"}}>
                    <WeaTop ecId={`${this && this.props && this.props.ecId || ''}_WeaTop@4c5qsv`} loading={loading} icon={<i className={topIcon} />} iconBgcolor={iconBgcolor} title={getLabel(388807,"任务查询")} style={{'height':height-115,'overflow': 'auto'}} >
                        <div className='g-taskSearch-condition'>
                        {/* <WeaNewScroll height={height-200}> */}
                           <ConditionNum ecId={`${this && this.props && this.props.ecId || ''}_ConditionNum@9i3sab`} listStore={taskStore} type="search" formB={formB} col={2} onEnterSearch={this.forwardQueryResult.bind(this)} forceRefresh={this.forceRefresh.bind(this)}></ConditionNum>
                        {/* </WeaNewScroll> */}
                        </div>
                        <div className='g-taskSearch-btns'>
                            {this.getSearchButtons()}
                        </div>
                    </WeaTop>
                </WeaRightMenu>
            </div>
        )
    }
    forceRefresh =(param) =>{
        const {taskStore} = this.props;
            //设置dataType
            // const nextDataType = nextProps.location.query.dataType;
        taskStore.setDataType("1");
        taskStore.init({ "isSuper":"1","isSuperPage":true,"fromSuperPage":false,"selectedTreeKey":0});
    }
    getSearchButtons() {
        const { taskStore } = this.props;
        const {clearFormFields} = taskStore;
        const btnStyle = {borderRadius: 3, width: 80}
        return [
            (<Button ecId={`${this && this.props && this.props.ecId || ''}_Button@xlln1o@search`} type="primary" style={btnStyle} onClick={this.forwardQueryResult.bind(this)}>{getLabel(197,"搜索")}</Button>),
            (<span style={{width:'15px', display:'inline-block'}}></span>),
            (<Button ecId={`${this && this.props && this.props.ecId || ''}_Button@823r61@reset`} type="ghost" style={btnStyle} onClick={()=>{taskStore.clearFormFields()}}>{getLabel(2022,"重置")}</Button>)
        ]
    }
    forwardQueryResult(){
        const { taskStore } = this.props;
        const path = "/task?dataType=1";
        this.context.router.push({
            pathname: "/main/govern"+path
        });
        //taskStore.init({ "isSuper":"0","isSuperPage":false,"fromSuperPage":true,"categoryid":null,"isSuperSearch":true,"selectedTreeKey":0});
        taskStore.doSearch({ "isSuper":"1","isSuperPage":false,"fromSuperPage":true,"categoryid":"0","isSuperSearch":true,"selectedTreeKey":0});
    }
    getRightMenu(){
        let btns = [];
    	btns.push({
            key: "search",
    		icon: <i className='icon-coms-search'/>,
            content: getLabel(197,"搜索"),
            onClick: this.forwardQueryResult.bind(this)
    	});
    	return btns;
    }
}

export default TaskSearch1;
